package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_LawService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by PC on 11/18/14.
 */
@Controller
public class Ad_LawController {
    @Autowired
    private Ad_LawService ad_lawService;

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/header/registerLaw", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> adminLaw(HttpServletRequest request, @RequestBody LuatDto lawDto) {
        return new JsonResponseDto<Integer>(ad_lawService.adminLaw(lawDto));
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/header/registerLawAddNew", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> adminLawAddNew(HttpServletRequest request, @RequestBody TapLuatDto lawDto) {
        return new JsonResponseDto<Integer>(ad_lawService.adminLawAddNew(lawDto));
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/header/registerLawDelete", method = RequestMethod.POST)
    public @ResponseBody
    JsonResponseDto<Integer> adminLawDelete(HttpServletRequest request, @RequestBody List<LuatDto> lawDto) {
        return new JsonResponseDto<Integer>(ad_lawService.adminLawDelete(lawDto));
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/ad_GetLawList", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<LuatDto>> getPostCategory(HttpServletRequest request) {
        return new JsonResponseDto<List<LuatDto>>(ad_lawService.getLawHypothesis(), JsonResponseCode.SUCCESS);
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(value = "/admin/ad_GetLawListReason", method = RequestMethod.GET)
    public @ResponseBody
    JsonResponseDto<List<LuatDto>> getLawReason(HttpServletRequest request) {
        return new JsonResponseDto<List<LuatDto>>(ad_lawService.getLawReason(), JsonResponseCode.SUCCESS);
    }

}
